//
//  YanTuVC.m
//  TuYouAPP
//
//  Created by L on 14-2-27.
//
//

#import "YanTuVC.h"

@interface YanTuVC ()
{
    UIScrollView *contentView;
}
@end
@interface nodeDetail : NSObject
@property (nonatomic,strong)NSString *name;
@end

@interface testnode : NSObject
@property (nonatomic,strong)nodeDetail *startDetail;
@property (nonatomic,strong)NSString *addrLength;
@property (nonatomic,strong)NSString *yantuStr;
@property (nonatomic,strong)nodeDetail *endDetail;
@end

@implementation nodeDetail

@end
@implementation testnode

@end
@implementation YanTuVC


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.view.backgroundColor = ColorRGB(249, 249, 249);
    }
    return self;
}

- (void)viewDidLoad
{
    self.mPageName = @"沿途";
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.Title = @"川藏路线沿途";
    self.LeftBarTitle = @"返回";
    self.RightBarTitle = @"确定";
    NSMutableArray *testArray = [[NSMutableArray alloc]init];
    
    [testArray addObject:@"西双版纳"];
    [testArray addObject:@"喜马拉雅"];
    [testArray addObject:@"昆明"];
    [testArray addObject:@"通麦大桥"];
    NSMutableArray *luduanArray = [[NSMutableArray alloc]init];
    [luduanArray addObject:@"西双版纳－喜马拉雅"];
        [luduanArray addObject:@"喜马拉雅-昆明"];
        [luduanArray addObject:@"昆明－通麦大桥"];
    
    if (SystemIsiOS7()) {
        contentView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64, 320, DEVICE_Height-64)];
        self.automaticallyAdjustsScrollViewInsets = NO;

    }
    else
    {
        contentView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 44, 320, DEVICE_Height-64)];
    }
    [self.view addSubview:contentView];

    float y = 20.0f;
    
    for (int i =0; i< testArray.count; i++) {
        
        NSString *dianStr = [testArray objectAtIndex:i];
        UIImageView *startimage = [[UIImageView alloc]initWithFrame:CGRectMake(50, y, 16, 16)];
        startimage .image = [UIImage imageNamed:@"yantu_dian.png"];
        [contentView addSubview:startimage];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)];//这个frame是初设的，没关系，后面还会重新设置其size。
        [label setNumberOfLines:0];
        label.text  = dianStr;
        UIFont *font = [UIFont systemFontOfSize:14];
        label.font = font;
        CGSize size = CGSizeMake(320,2000);
        CGSize labelsize = [dianStr sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByWordWrapping];
        [label setFrame:CGRectMake(100  ,y+10, labelsize.width, labelsize.height)];
        UIImageView *locationView = [[UIImageView alloc]initWithFrame:CGRectMake(85, y+11, 10, 14)];
        locationView.image = [UIImage imageNamed:@"weizi.png"];
        
        
        UIButton *dianBtn = [[UIButton alloc]initWithFrame:CGRectMake(70, y, labelsize.width + 40, 38)];
        UIImage *aimage =[UIImage imageNamed:@"yantukuangnew.png"];
        aimage = [aimage resizableImageWithCapInsets:UIEdgeInsetsMake(12, 17, 13, 25) resizingMode:UIImageResizingModeStretch];
        [contentView addSubview:dianBtn];
                [dianBtn setBackgroundImage:aimage forState:UIControlStateNormal];

        
          [contentView addSubview:label];
        [contentView addSubview:locationView];
        if (i!=testArray.count-1) {
            NSString *duanstr = [luduanArray objectAtIndex:i];
            y+=50;
            [luduanArray objectAtIndex:i];
            UIImageView *duanimage = [[UIImageView alloc]initWithFrame:CGRectMake(50, y, 16, 16)];
            duanimage .image = [UIImage imageNamed:@"yantu_yantu.png"];
            [contentView addSubview:duanimage];

            
            UIButton *duanBtn = [[UIButton alloc]initWithFrame:CGRectMake(70, y, 240, 67)];
   
            
            
            [contentView addSubview:duanBtn];
            UILabel *duanlabel = [[UILabel  alloc]initWithFrame:CGRectMake(85, y, 150, 20)];
            duanlabel.text =@"G318,123KM";
            duanlabel.font = [UIFont systemFontOfSize:12];
            duanlabel.textColor = [UIColor redColor];
            [contentView addSubview:duanlabel];
            UILabel *duanlabelname = [[UILabel alloc]initWithFrame:CGRectMake(85, y+15, 250, 20)];
            duanlabelname.font = [UIFont systemFontOfSize:12];
            duanlabelname.text = duanstr;
            
            UIImageView *xianView = [[UIImageView alloc]initWithFrame:CGRectMake(85, y+35, 220, 0.5)];
            xianView.image = [UIImage imageNamed:@"tongyongxian.png"];
            
            [contentView addSubview:xianView];
            [contentView addSubview:duanlabelname];
            
            NSString *tujingstr = @"二郎山隧道,二郎山隧道,二郎山隧道,二郎山隧道,二郎山隧道,二郎山隧道,二郎山隧道,二郎山隧道,二郎山隧道,二郎山隧道,二郎山隧道,二郎山隧道,二郎山隧道,二郎山隧道";
            font = [UIFont systemFontOfSize:12];
            
            size = CGSizeMake(220,2000);
            labelsize = [tujingstr sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByWordWrapping];
            
            UILabel *tujingLabel =[[UILabel alloc] initWithFrame:CGRectMake(85  ,y+40, labelsize.width, labelsize.height)];
            [tujingLabel setNumberOfLines:0];
            tujingLabel.textColor = [UIColor grayColor];
            tujingLabel.text  = tujingstr;
            tujingLabel.font = font;
            [contentView addSubview:tujingLabel];
            CGRect rect = duanBtn.frame;
            rect.size.height += labelsize.height-15;
            duanBtn.frame = rect;
            UIImage *image = [UIImage imageNamed:@"yantu_kuang1.png"];
            
            image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(12, 17, 13, 25) resizingMode:UIImageResizingModeStretch];
            [duanBtn setBackgroundImage:image forState:UIControlStateNormal ];
            
            
            y+=duanBtn.frame.size.height+15;

        }


    }
    UIImageView *xianimage = [[UIImageView alloc]initWithFrame:CGRectMake(57, 0, 3, y+50)];
    xianimage.image = [UIImage imageNamed:@"yantu_xian.png"];
    [contentView addSubview:xianimage];
    [contentView sendSubviewToBack:xianimage];
    [contentView setContentSize:CGSizeMake(320, y+50)];
    
    
}
-(void)leftBtnTouched:(id)sender
{
    [self.navigationController popViewControllerAnimated: YES];
}
-(void)rightBtnTouched:(id)sender
{
    
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
